package com.project.service.impl;

import com.project.bean.ManBean;
import com.project.mapper.IManMapper;
import com.project.service.IManService;
import org.apache.ibatis.session.SqlSession;

import java.time.LocalDate;

/**
 * 公民接口实现类
 */
public class ManServiceImpl extends BaseService implements IManService {
    @Override
    public void add(ManBean manBean) {
        //得到session
        SqlSession session = this.getSqlSession();
        //得到mapper接口的实现类对象
        IManMapper mapper = session.getMapper(IManMapper.class);
        //调用mapper中的add
        mapper.add(manBean);
        //提交事务
        session.commit();
        //关闭session
        session.close();
    }

    @Override
    public void del(int id) {
        SqlSession session = this.getSqlSession();
        IManMapper mapper =session.getMapper(IManMapper.class);
        mapper.del(id);
        session.commit();
        session.close();
    }

    @Override
    public void update(int id, LocalDate birth) {
        SqlSession session = this.getSqlSession();
        IManMapper mapper =session.getMapper(IManMapper.class);
        mapper.update(id,birth);
        session.commit();
        session.close();
    }
}
